﻿<%@ Page Language="C#" MasterPageFile="~/MasterPages/RestaurantMaster.master" CodeFile="adddish.aspx.cs" Inherits="restaurant_adddish" 
AutoEventWireup="true"%>
<asp:Content ID="Content1" ContentPlaceHolderID="Restaurant_ContentPlaceHolder" Runat="Server">
<div style="vertical-align:top; overflow:auto;width:auto; height:auto; font-size:medium; background-color:#FFF7E7;">
    <asp:Repeater ID="category_repeater" runat="server">
    <ItemTemplate>
        <table>
            <tr>
            <th>
            <asp:Label ID="category_id_label" Visible="false" runat="server" Text='<%# Bind("Id") %>'></asp:Label>
            <%#Eval("Name")%><asp:CheckBox ID="choose_checkbox" runat="server" Checked="false"/></th>
            </tr>
            <tr><th>
            <asp:DataList ID="categorydish_datalist" runat="server" RepeatDirection="Horizontal" CellSpacing="1" CellPadding="3" 
            DataSource='<%# Eval("CategoryDishes")%>' DataKeyField="Id" RepeatColumns="5" Font-Bold="false">
            <ItemTemplate>
                <%# Eval("Name") %><%#Eval("Price") %>&#165;<asp:CheckBox ID="choose_checkbox" runat="server" Checked="false" TextAlign="Right"/>
            </ItemTemplate>
            <ItemStyle ForeColor="#8C4510" HorizontalAlign="Left"/>
            </asp:DataList></th></tr>
        </table>
    </ItemTemplate>
    </asp:Repeater>
    
    <table>
        <tr><td style="height:inherit"><asp:Button ID="del_Category_and_dish_btn" runat="server" OnClick="OnClickDelAtMenuBtn" Text="删除"></asp:Button></td>
        <td style="width:auto"><asp:Label ID="notice_label" runat="server"></asp:Label></td>
        </tr>
    </table>
</div>

<div>
    <div><table border="1px" style="height:inherit;">
        <tr>
            <td style="width:6%; text-align:center">
                <asp:Label ID="similar_dish_id_label" runat="server" visible="false"></asp:Label>
                <asp:Label ID="dishname_label" runat="server" Text="菜名"></asp:Label></td>
            <td style="width:12%"><asp:TextBox ID="dishname_textbox" runat="server" AutoPostBack="True" OnTextChanged="OnDishTextChanged"></asp:TextBox>
                                  <asp:RequiredFieldValidator ID="dishname_required_validator" runat="server" 
            ControlToValidate="dishname_textbox" Display="Dynamic" ErrorMessage="*" ValidationGroup="adddish_group">
            </asp:RequiredFieldValidator>
            <asp:RegularExpressionValidator ID="dishname_regex_validator" ControlToValidate="dishname_textbox" Display="Dynamic"
                    runat="server" ValidationGroup="adddish_group" ErrorMessage="菜名不超过十个字" ValidationExpression="(.{0,20})">
                    </asp:RegularExpressionValidator></td>
            <td style="width:6%;text-align:center"><asp:Label ID="price_label" runat="server" Text="价格"></asp:Label></td>
            <td style="width:6%"><asp:TextBox ID="price_textbox" runat="server" Width="85%" ></asp:TextBox>
                                  <asp:RequiredFieldValidator ID="price_required_validator" runat="server" 
            ControlToValidate="price_textbox" Display="Dynamic" ErrorMessage="*" ValidationGroup="adddish_group">
            </asp:RequiredFieldValidator><asp:RegularExpressionValidator ID="price_expression_validator" runat="server"
            ControlToValidate="price_textbox" Display="Dynamic" ErrorMessage="请输入价格如 7.0" ValidationExpression="([\d.]{1,3})" ValidationGroup="adddish_group"></asp:RegularExpressionValidator></td>
            <td style="width:6%; text-align:center"><asp:Label ID="dishcategory_label" runat="server" Text="类别"></asp:Label></td>
            <td style="width:12%"><asp:DropDownList ID="category_dropdownlist" runat="server" Width="100%"
             DataValueField="Id" DataTextField="Name">
             </asp:DropDownList>
            <asp:RequiredFieldValidator ID="category_required_validator" runat="server" ControlToValidate="category_dropdownlist" Display="Dynamic" ErrorMessage="请选择分类"
            InitialValue="--选择分类--" ValidationGroup="adddish_group"></asp:RequiredFieldValidator></td>
            <td style="width:6%; text-align:center"><asp:Label ID="dishdisc_label" runat="server" Text="描述"></asp:Label></td>
            <td style="width:27%"><asp:TextBox ID="dishdisc_textbox" runat="server" Width="96%" Text="N/A" ></asp:TextBox></td>
        </tr>
        <tr>
            <td><asp:Label ID="similar_dishes_label" runat="server" Text="相似菜品" visible="false"></asp:Label></td>
            <td colspan="5">
                <asp:ListBox id="similar_dishes_listbox" width="200px" height="120px" runat="server" DataTextField="Name" DataValueField="Id"
                 AutoPostBack="true" visible="false" OnSelectedIndexChanged="OnSelectedSimilarDishChanged"></asp:ListBox>
            </td>
            <td><asp:Button ID="add_dish_btn" runat="server" Text="提交菜品" OnClick="OnClickManualAddBtn" CausesValidation="true" ValidationGroup="adddish_group"/></td>
        </tr>
        <tr>
            <td>分类名称</td><td colspan="2"><asp:TextBox ID="category_name_textbox" runat="server" Width="98%"></asp:TextBox></td>
            <td>分类描述</td><td colspan="2"><asp:TextBox ID="category_description_textbox" runat="server" Width="98%"></asp:TextBox></td>
            <td><asp:Button ID="AddCategoryBtn" runat="server" OnClick="OnClickAddCategory" Text="添加分类"></asp:Button></td>
        </tr>
    </table></div>
</div>
</asp:Content>

